//
//  MonsterInfo.m
//  SpaceStorm
//
//  Created by 祥 雍 on 13-5-26.
//  Copyright (c) 2013年 __MyCompanyName__. All rights reserved.
//
// 战役敌军装备表(怪物表)的信息类

#import "MonsterInfo.h"
#import "Variable.h"

@implementation MonsterInfo

@synthesize shipId = _shipId;
@synthesize shipName = _shipName;
@synthesize baseShipName = _baseShipName;

@synthesize attackSystem1 = _attackSystem1;
@synthesize attackSystem2 = _attackSystem2;
@synthesize attackSystem3 = _attackSystem3;
@synthesize attackSystem4 = _attackSystem4;
@synthesize attackSystem5 = _attackSystem5;
@synthesize attackSystem6 = _attackSystem6;
@synthesize attackSystem7 = _attackSystem7;
@synthesize attackSystem8 = _attackSystem8;

@synthesize defenseSystem1 = _defenseSystem1;
@synthesize defenseSystem2 = _defenseSystem2;
@synthesize defenseSystem3 = _defenseSystem3;
@synthesize defenseSystem4 = _defenseSystem4;
@synthesize defenseSystem5 = _defenseSystem5;
@synthesize defenseSystem6 = _defenseSystem6;
@synthesize defenseSystem7 = _defenseSystem7;
@synthesize defenseSystem8 = _defenseSystem8;

@synthesize servoSystem1 = _servoSystem1;
@synthesize servoSystem2 = _servoSystem2;
@synthesize servoSystem3 = _servoSystem3;
@synthesize servoSystem4 = _servoSystem4;
@synthesize servoSystem5 = _servoSystem5;
@synthesize servoSystem6 = _servoSystem6;
@synthesize servoSystem7 = _servoSystem7;
@synthesize servoSystem8 = _servoSystem8;

@synthesize airplane1 = _airplane1;
@synthesize airplane2 = _airplane2;
@synthesize airplane3 = _airplane3;
@synthesize airplane4 = _airplane4;
@synthesize airplane5 = _airplane5;
@synthesize airplane6 = _airplane6;
@synthesize airplane7 = _airplane7;
@synthesize airplane8 = _airplane8;


@synthesize meritoriousMilitary = _meritoriousMilitary;
@synthesize militarySupplies = _militarySupplies;
@synthesize falling = _falling;

@synthesize attackSystemIds = _attackSystemIds;
@synthesize defenseSystemIds = _defenseSystemIds;
@synthesize servoSystemIds = _servoSystemIds;
@synthesize airplaneIds = _airplaneIds;


+(id) infoWithTbxml:(TBXMLElement *)tbxml
{
    return [[[self alloc] initWithTbxml:tbxml] autorelease]; 
}

-(id) initWithTbxml:(TBXMLElement *)tbxml
{
    self = [super init]; 
	
	if (self!= nil) 
    {
        self.attackSystemIds    = [NSMutableDictionary dictionaryWithCapacity:8];
        self.defenseSystemIds   = [NSMutableDictionary dictionaryWithCapacity:8];
        self.servoSystemIds     = [NSMutableDictionary dictionaryWithCapacity:8];
        self.airplaneIds        = [NSMutableDictionary dictionaryWithCapacity:8];
        
        //舰船id	
        self.shipId = [[TBXML valueOfAttributeNamed:@"shipId" forElement:tbxml] intValue];
        if(showXMLLog == YES) CCLOG(@"舰船id:%d", self.shipId);
        
        //舰船名	
        self.shipName = [TBXML valueOfAttributeNamed:@"shipName" forElement:tbxml];
        if(showXMLLog == YES) CCLOG(@"舰船名:%@", self.shipName);
        
        //基础船体id	
        self.baseShipName = [[TBXML valueOfAttributeNamed:@"baseShipName" forElement:tbxml] intValue];
        if(showXMLLog == YES) CCLOG(@"基础船体id:%d", self.baseShipName);
        
        //攻击系统1
        self.attackSystem1 = [[TBXML valueOfAttributeNamed:@"attackSystem1" forElement:tbxml] intValue];
        if(self.attackSystem1 != 0) //非0的ID加入到组
        {
            [self.attackSystemIds setObject:[NSNumber numberWithInt:self.attackSystem1] forKey:@"1"];
        }
        if(showXMLLog == YES) CCLOG(@"攻击系统1:%d", self.attackSystem1);

        //攻击系统2	
        self.attackSystem2 = [[TBXML valueOfAttributeNamed:@"attackSystem2" forElement:tbxml] intValue];
        if(self.attackSystem2 != 0) //非0的ID加入到组
        {
            [self.attackSystemIds setObject:[NSNumber numberWithInt:self.attackSystem2] forKey:@"2"];
        }
        if(showXMLLog == YES) CCLOG(@"攻击系统2:%d", self.attackSystem2);
        
        //攻击系统3	
        self.attackSystem3 = [[TBXML valueOfAttributeNamed:@"attackSystem3" forElement:tbxml] intValue];
        if(self.attackSystem3 != 0) //非0的ID加入到组
        {
            [self.attackSystemIds setObject:[NSNumber numberWithInt:self.attackSystem3] forKey:@"3"];
        }
        if(showXMLLog == YES) CCLOG(@"攻击系统3:%d", self.attackSystem3);
        
        //攻击系统4
        self.attackSystem4 = [[TBXML valueOfAttributeNamed:@"attackSystem4" forElement:tbxml] intValue];
        if(self.attackSystem4 != 0) //非0的ID加入到组
        {
            [self.attackSystemIds setObject:[NSNumber numberWithInt:self.attackSystem4] forKey:@"4"];
        }
        if(showXMLLog == YES) CCLOG(@"攻击系统4:%d", self.attackSystem4);
        
        //攻击系统5	
        self.attackSystem5 = [[TBXML valueOfAttributeNamed:@"attackSystem5" forElement:tbxml] intValue];
        if(self.attackSystem5 != 0) //非0的ID加入到组
        {
            [self.attackSystemIds setObject:[NSNumber numberWithInt:self.attackSystem5] forKey:@"5"];
        }
        if(showXMLLog == YES) CCLOG(@"攻击系统5:%d", self.attackSystem5);
        
        //攻击系统6	
        self.attackSystem6 = [[TBXML valueOfAttributeNamed:@"attackSystem6" forElement:tbxml] intValue];
        if(self.attackSystem6 != 0) //非0的ID加入到组
        {
            [self.attackSystemIds setObject:[NSNumber numberWithInt:self.attackSystem6] forKey:@"6"];
        }
        if(showXMLLog == YES) CCLOG(@"攻击系统6:%d", self.attackSystem6);

        //攻击系统7
        self.attackSystem7 = [[TBXML valueOfAttributeNamed:@"attackSystem7" forElement:tbxml] intValue];
        if(self.attackSystem7 != 0) //非0的ID加入到组
        {
            [self.attackSystemIds setObject:[NSNumber numberWithInt:self.attackSystem7] forKey:@"7"];
        }
        if(showXMLLog == YES) CCLOG(@"攻击系统7:%d", self.attackSystem7);
        
        //攻击系统8	
        self.attackSystem8 = [[TBXML valueOfAttributeNamed:@"attackSystem8" forElement:tbxml] intValue];
        if(self.attackSystem8 != 0) //非0的ID加入到组
        {
            [self.attackSystemIds setObject:[NSNumber numberWithInt:self.attackSystem8] forKey:@"8"];
        }
        if(showXMLLog == YES) CCLOG(@"攻击系统8:%d", self.attackSystem8);
        
        //防御系统1
        self.defenseSystem1 = [[TBXML valueOfAttributeNamed:@"defenseSystem1" forElement:tbxml] intValue];
        if(self.defenseSystem1 != 0) //非0的ID加入到组
        {
            [self.defenseSystemIds setObject:[NSNumber numberWithInt:self.defenseSystem1] forKey:@"1"];
        }
        if(showXMLLog == YES) CCLOG(@"防御系统1:%d", self.defenseSystem1);
        
        //防御系统2	
        self.defenseSystem2 = [[TBXML valueOfAttributeNamed:@"defenseSystem2" forElement:tbxml] intValue];
        if(self.defenseSystem2 != 0) //非0的ID加入到组
        {
            [self.defenseSystemIds setObject:[NSNumber numberWithInt:self.defenseSystem2] forKey:@"2"];
        }
        if(showXMLLog == YES) CCLOG(@"防御系统2:%d", self.defenseSystem2);
        
        //防御系统3	
        self.defenseSystem3 = [[TBXML valueOfAttributeNamed:@"defenseSystem3" forElement:tbxml] intValue];
        if(self.defenseSystem3 != 0) //非0的ID加入到组
        {
            [self.defenseSystemIds setObject:[NSNumber numberWithInt:self.defenseSystem3] forKey:@"3"];
        }
        if(showXMLLog == YES) CCLOG(@"防御系统3:%d", self.defenseSystem3);
        
        //防御系统4	
        self.defenseSystem4 = [[TBXML valueOfAttributeNamed:@"defenseSystem4" forElement:tbxml] intValue];
        if(self.defenseSystem4 != 0) //非0的ID加入到组
        {
            [self.defenseSystemIds setObject:[NSNumber numberWithInt:self.defenseSystem4] forKey:@"4"];
        }
        if(showXMLLog == YES) CCLOG(@"防御系统4:%d", self.defenseSystem4);
        
        //防御系统5	
        self.defenseSystem5 = [[TBXML valueOfAttributeNamed:@"defenseSystem5" forElement:tbxml] intValue];
        if(self.defenseSystem5 != 0) //非0的ID加入到组
        {
            [self.defenseSystemIds setObject:[NSNumber numberWithInt:self.defenseSystem5] forKey:@"5"];
        }
        if(showXMLLog == YES) CCLOG(@"防御系统5:%d", self.defenseSystem5);
        
        //防御系统6	
        self.defenseSystem6 = [[TBXML valueOfAttributeNamed:@"defenseSystem6" forElement:tbxml] intValue];
        if(self.defenseSystem6 != 0) //非0的ID加入到组
        {
            [self.defenseSystemIds setObject:[NSNumber numberWithInt:self.defenseSystem6] forKey:@"6"];
        }
        if(showXMLLog == YES) CCLOG(@"防御系统6:%d", self.defenseSystem6);
        
        //防御系统7	
        self.defenseSystem7 = [[TBXML valueOfAttributeNamed:@"defenseSystem7" forElement:tbxml] intValue];
        if(self.defenseSystem7 != 0) //非0的ID加入到组
        {
            [self.defenseSystemIds setObject:[NSNumber numberWithInt:self.defenseSystem7] forKey:@"7"];
        }
        if(showXMLLog == YES) CCLOG(@"防御系统7:%d", self.defenseSystem7);
        
        //防御系统8	
        self.defenseSystem8 = [[TBXML valueOfAttributeNamed:@"defenseSystem8" forElement:tbxml] intValue];
        if(self.defenseSystem8 != 0) //非0的ID加入到组
        {
            [self.defenseSystemIds setObject:[NSNumber numberWithInt:self.defenseSystem8] forKey:@"8"];
        }
        if(showXMLLog == YES) CCLOG(@"防御系统8:%d", self.defenseSystem8);
        
        //辅助系统1	
        self.servoSystem1 = [[TBXML valueOfAttributeNamed:@"servoSystem1" forElement:tbxml] intValue];
        if(self.servoSystem1 != 0) //非0的ID加入到组
        {
            [self.servoSystemIds setObject:[NSNumber numberWithInt:self.servoSystem1] forKey:@"1"];
        }
        if(showXMLLog == YES) CCLOG(@"辅助系统1:%d", self.servoSystem1);
        
        //辅助系统2
        self.servoSystem2 = [[TBXML valueOfAttributeNamed:@"servoSystem2" forElement:tbxml] intValue];
        if(self.servoSystem2 != 0) //非0的ID加入到组
        {
            [self.servoSystemIds setObject:[NSNumber numberWithInt:self.servoSystem2] forKey:@"2"];
        }
        if(showXMLLog == YES) CCLOG(@"辅助系统2:%d", self.servoSystem2);
        
        //辅助系统3	
        self.servoSystem3 = [[TBXML valueOfAttributeNamed:@"servoSystem3" forElement:tbxml] intValue];
        if(self.servoSystem3 != 0) //非0的ID加入到组
        {
            [self.servoSystemIds setObject:[NSNumber numberWithInt:self.servoSystem3] forKey:@"3"];
        }
        if(showXMLLog == YES) CCLOG(@"辅助系统3:%d", self.servoSystem3);
        
        //辅助系统4	
        self.servoSystem4 = [[TBXML valueOfAttributeNamed:@"servoSystem4" forElement:tbxml] intValue];
        if(self.servoSystem4 != 0) //非0的ID加入到组
        {
            [self.servoSystemIds setObject:[NSNumber numberWithInt:self.servoSystem4] forKey:@"4"];
        }
        if(showXMLLog == YES) CCLOG(@"辅助系统4:%d", self.servoSystem4);
        
        //辅助系统5	
        self.servoSystem5 = [[TBXML valueOfAttributeNamed:@"servoSystem5" forElement:tbxml] intValue];
        if(self.servoSystem5 != 0) //非0的ID加入到组
        {
            [self.servoSystemIds setObject:[NSNumber numberWithInt:self.servoSystem5] forKey:@"5"];
        }
        if(showXMLLog == YES) CCLOG(@"辅助系统5:%d", self.servoSystem5);
        
        //辅助系统6
        self.servoSystem6 = [[TBXML valueOfAttributeNamed:@"servoSystem6" forElement:tbxml] intValue];
        if(self.servoSystem6 != 0) //非0的ID加入到组
        {
            [self.servoSystemIds setObject:[NSNumber numberWithInt:self.servoSystem6] forKey:@"6"];
        }
        if(showXMLLog == YES) CCLOG(@"辅助系统6:%d", self.servoSystem6);
        
        //辅助系统7	
        self.servoSystem7 = [[TBXML valueOfAttributeNamed:@"servoSystem7" forElement:tbxml] intValue];
        if(self.servoSystem7 != 0) //非0的ID加入到组
        {
            [self.servoSystemIds setObject:[NSNumber numberWithInt:self.servoSystem7] forKey:@"7"];
        }
        if(showXMLLog == YES) CCLOG(@"辅助系统7:%d", self.servoSystem7);
        
        //辅助系统8	
        self.servoSystem8 = [[TBXML valueOfAttributeNamed:@"servoSystem8" forElement:tbxml] intValue];
        if(self.servoSystem8 != 0) //非0的ID加入到组
        {
            [self.servoSystemIds setObject:[NSNumber numberWithInt:self.servoSystem8] forKey:@"8"];
        }
        if(showXMLLog == YES) CCLOG(@"辅助系统8:%d", self.servoSystem8);
        
        //舰载机1
        self.airplane1 = [[TBXML valueOfAttributeNamed:@"airplane1" forElement:tbxml] intValue];
        if(self.airplane1 != 0) //非0的ID加入到组
        {
            [self.airplaneIds setObject:[NSNumber numberWithInt:self.airplane1] forKey:@"1"];
        }
        if(showXMLLog == YES) CCLOG(@"舰载机1:%d", self.airplane1);
        
        //舰载机2
        self.airplane2 = [[TBXML valueOfAttributeNamed:@"airplane2" forElement:tbxml] intValue];
        if(self.airplane2 != 0) //非0的ID加入到组
        {
            [self.airplaneIds setObject:[NSNumber numberWithInt:self.airplane2] forKey:@"2"];
        }
        if(showXMLLog == YES) CCLOG(@"舰载机2:%d", self.airplane2);
        
        //舰载机3
        self.airplane3 = [[TBXML valueOfAttributeNamed:@"airplane3" forElement:tbxml] intValue];
        if(self.airplane3 != 0) //非0的ID加入到组
        {
            [self.airplaneIds setObject:[NSNumber numberWithInt:self.airplane3] forKey:@"3"];
        }
        if(showXMLLog == YES) CCLOG(@"舰载机3:%d", self.airplane3);
        
        //舰载机4
        self.airplane4 = [[TBXML valueOfAttributeNamed:@"airplane4" forElement:tbxml] intValue];
        if(self.airplane4 != 0) //非0的ID加入到组
        {
            [self.airplaneIds setObject:[NSNumber numberWithInt:self.airplane4] forKey:@"4"];
        }
        if(showXMLLog == YES) CCLOG(@"舰载机4:%d", self.airplane4);
        
        //舰载机5
        self.airplane5 = [[TBXML valueOfAttributeNamed:@"airplane5" forElement:tbxml] intValue];
        if(self.airplane5 != 0) //非0的ID加入到组
        {
            [self.airplaneIds setObject:[NSNumber numberWithInt:self.airplane5] forKey:@"5"];
        }
        if(showXMLLog == YES) CCLOG(@"舰载机5:%d", self.airplane5);
        
        //舰载机6
        self.airplane6 = [[TBXML valueOfAttributeNamed:@"airplane6" forElement:tbxml] intValue];
        if(self.airplane6 != 0) //非0的ID加入到组
        {
            [self.airplaneIds setObject:[NSNumber numberWithInt:self.airplane6] forKey:@"6"];
        }
        if(showXMLLog == YES) CCLOG(@"舰载机6:%d", self.airplane6);
        
        //舰载机7
        self.airplane7 = [[TBXML valueOfAttributeNamed:@"airplane7" forElement:tbxml] intValue];
        if(self.airplane7 != 0) //非0的ID加入到组
        {
            [self.airplaneIds setObject:[NSNumber numberWithInt:self.airplane7] forKey:@"7"];
        }
        if(showXMLLog == YES) CCLOG(@"舰载机7:%d", self.airplane7);
        
        //舰载机8
        self.airplane8 = [[TBXML valueOfAttributeNamed:@"airplane8" forElement:tbxml] intValue];
        if(self.airplane8 != 0) //非0的ID加入到组
        {
            [self.airplaneIds setObject:[NSNumber numberWithInt:self.airplane8] forKey:@"8"];
        }
        if(showXMLLog == YES) CCLOG(@"舰载机8:%d", self.airplane8);
        
        //战功	
        self.meritoriousMilitary = [[TBXML valueOfAttributeNamed:@"meritoriousMilitary" forElement:tbxml] intValue];
        if(showXMLLog == YES) CCLOG(@"战功:%d", self.meritoriousMilitary);
        
        //军需	
        self.militarySupplies = [[TBXML valueOfAttributeNamed:@"militarySupplies" forElement:tbxml] intValue];
        if(showXMLLog == YES) CCLOG(@"军需:%d", self.militarySupplies);
        
        //掉落		
        self.falling = [[TBXML valueOfAttributeNamed:@"falling" forElement:tbxml] intValue];
        if(showXMLLog == YES) CCLOG(@"掉落:%d", self.falling);
    }
    
     return self;
}

-(void) dealloc
{
    if(self.shipName)
    {
        [self.shipName release];
        self.shipName = nil;
    }
    
    if(self.attackSystemIds)
    {
        [self.attackSystemIds removeAllObjects];
        [self.attackSystemIds release];
        self.attackSystemIds = nil;
    }
    
    if(self.defenseSystemIds)
    {
        [self.defenseSystemIds removeAllObjects];
        [self.defenseSystemIds release];
        self.defenseSystemIds = nil;
    }
    
    if(self.servoSystemIds)
    {
        [self.servoSystemIds removeAllObjects];
        [self.servoSystemIds release];
        self.servoSystemIds = nil;
    }
    
    if(self.airplaneIds)
    {
        [self.airplaneIds removeAllObjects];
        [self.airplaneIds release];
        self.airplaneIds = nil;
    }
    
    // 不要忘记调用"super dealloc" 
    [super dealloc];
}

@end
